<?php

namespace App\Models;

class AdminRole extends Base
{
    protected $table = 'admin_roles';

    protected $guarded = [];

    /**
     * 是否被使用过
     */
    public static function isUsed($id)
    {
        if (!$id) {
            return ['code' => 0, 'msg' => '参数错误'];
        }
        // 是否有管理员
        $roleUser = AdminRoleUser::where('role_id', $id)->select('id')->first();
        if ($roleUser) {
            return ['code' => 0, 'msg' => '该角色下有管理员，请先删除管理员'];
        }

        return ['code' => 1, 'msg' => ''];
    }
}
